from tkinter import font
from wordcloud import WordCloud
import jieba
import pandas as pd
import tqdm
data = pd.read_excel("data/最新数据——豆瓣社恐抱团取暖和社交能力复健小组数据11.22.xlsx", "社恐抱团取暖小组article")["article"].to_list()


texts = []
for text in tqdm.tqdm(data):
    if isinstance(text, str):
        ls = jieba.lcut(text)
        texts.extend(ls)

texts = " ".join(texts)



stopwords = [word.strip() for word in open("cn_stopwords.txt", "r").readlines()]


wc = WordCloud(
    font_path = "Hei.ttf",
                width = 1000,
                height = 700,
                background_color='white',
                max_words=100,
                stopwords=stopwords)

wc.generate(texts)
wc.to_file("社恐抱团取暖小组article.png")